package Xiancheng;
/**
 * 买票的线程
 * @author AcerMr
 *
 */
public class TicketThread implements Runnable
{
	private static int  total = 20;
	@Override
	public void run()
	{
		
		while (total>0)
		{
			try
			{
				Thread.sleep(200);
			} catch (InterruptedException e)
			{
				e.printStackTrace();
			}
			synchronized(this)
			{
				if(total>0) 
				{
					System.out.println(Thread.currentThread()+"买票"+total);
					total --;
				}
			}
		}
	}
	
}
